package com.ruoyi.web.controller.datastatistics;


import com.ruoyi.basedata.domain.RealtimegatherdataXbView;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.datastatistics.service.INotCopiedBackXbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("/basedata/notcopiedback")
public class NotCopiedBackXbController extends BaseController {

    @Autowired
    private INotCopiedBackXbService iNotCopiedBackXbService;


    //   查询今天没有抄回来的数据
    @PreAuthorize("@ss.hasPermi('datastatistics:notcopiedback:list')")
    @GetMapping("/notcopylist")
    public TableDataInfo didNotCopyBackToday(RealtimegatherdataXbView realtimegatherdataXbView){
        System.out.println(realtimegatherdataXbView);
        startPage();
        List<RealtimegatherdataXbView> noMeterReadData = iNotCopiedBackXbService.didNotCopyBackToday(realtimegatherdataXbView);
        noMeterReadData.forEach(System.out::println);
        return getDataTable(noMeterReadData);
    }


    //   查询历史数据中某个日期之间没有抄回来的数据
    @PreAuthorize("@ss.hasPermi('datastatistics:notcopiedback:list')")
    @GetMapping("/historyNotCopyBacklist")
    public TableDataInfo historyNotCopyBack(RealtimegatherdataXbView realtimegatherdataXbView) throws ParseException {
        System.out.println(realtimegatherdataXbView);
        startPage();
        List<RealtimegatherdataXbView> noMeterReadData = iNotCopiedBackXbService.historyNotCopyBack(realtimegatherdataXbView);
        noMeterReadData.forEach(System.out::println);
        return getDataTable(noMeterReadData);
    }




    @PreAuthorize("@ss.hasPermi('datastatistics:notcopiedback:list')")
    @Log(title = "未抄表数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RealtimegatherdataXbView realtimegatherdataXbView) {
        List<RealtimegatherdataXbView> list = iNotCopiedBackXbService.didNotCopyBackToday(realtimegatherdataXbView);
        ExcelUtil<RealtimegatherdataXbView> util = new ExcelUtil<RealtimegatherdataXbView>(RealtimegatherdataXbView.class);
        util.exportExcel(response, list, "小表实时未抄表数据");
    }

    @PreAuthorize("@ss.hasPermi('datastatistics:notcopiedback:list')")
    @Log(title = "未抄表数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export2")
    public void export2(HttpServletResponse response, RealtimegatherdataXbView realtimegatherdataXbView) {
        List<RealtimegatherdataXbView> list = iNotCopiedBackXbService.historyNotCopyBack(realtimegatherdataXbView);
        ExcelUtil<RealtimegatherdataXbView> util = new ExcelUtil<RealtimegatherdataXbView>(RealtimegatherdataXbView.class);
        util.exportExcel(response, list, "小表历史未抄表数据");
    }




}
